#ifndef __COMPONENT_SICKNESS_H__
#define __COMPONENT_SICKNESS_H__

#include "Component.hpp"

namespace PocketSurvival
{
    struct ComponentPlayer;
    struct ComponentSickness : public Component
    {
        // 疾病持续时间
        float sicknessDuration = 0.0f;
        // 上一次恶心的时间
        double lastNauseaTime = 0.0f;

        ComponentPlayer *componentPlayer;
        
        inline bool isSick();
        void nauseaEffect();
        void startSickness();
        void endSickness();

        virtual void update(float dt) override;
        virtual const std::string &getName() const override;
        static const std::string &GetName();
        virtual void load(const nlohmann::json &jsonData) override;
        virtual void save(nlohmann::json &jsonData) override;
        virtual void saveToMsgJson(nlohmann::json &jsonData) override;
    };

    inline bool ComponentSickness::isSick()
    {
        return sicknessDuration > 0.0f;
    }

} // namespace PocketSurvival

#endif
